package com.future.north.controller;

import com.alibaba.fastjson.JSONObject;
import com.future.north.api.DubboMonitorService;
import com.future.north.api.UserService;
import com.future.north.api.model.DubboMonitor;
import com.future.north.api.model.User;
import com.future.north.aspect.trace.TraceLog;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/dubbo")
@TraceLog(key = "helloController")
public class DubboMonitorController extends BaseController {
    @Autowired
    private DubboMonitorService dubboMonitorService;

    @RequestMapping("/index")
    public String index() {
        Page<DubboMonitor> persons = dubboMonitorService.findByPage(1, 2);
        // 需要把Page包装成PageInfo对象才能序列化。该插件也默认实现了一个PageInfo
        PageInfo<DubboMonitor> pageInfo = new PageInfo<>(persons);
        System.out.println(JSONObject.toJSON(pageInfo));
        return "dubbo/index";
    }

    @RequestMapping("/list")
    public String list() {
        return "";
    }
}
